home *** CD-ROM | disk | FTP | other *** search
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- class TEST_ARRAY_REFERENCE1
- --
- -- Test Reference/ARRAY.
- --
-
- creation {ANY}
- make
-
- feature {ANY}
-
- a, a2: ARRAY[CAT];
- c1,c2,c3,cv: CAT;
- i: INTEGER;
-
- a_cat: ARRAY[CAT];
- a_animal: ARRAY[ANIMAL];
-
- make is
- do
- !!c1;
- !!c2;
- !!c3;
-
- !!a.make(1,0);
- is_true(a.lower = 1);
- is_true(a.upper = 0);
- is_true(a.count = 0);
- is_true(a.empty);
- a.make(1,1);
- is_true(a.count = 1);
- is_true(a.lower = 1);
- is_true(a.upper = 1);
- is_true(a.item(1) = Void);
-
- !!a.make(1,4);
- is_true(a.count = 4);
- from
- i := 1;
- until
- i > a.count
- loop
- is_true(a.item(i) = Void);
- i := i + 1;
- end;
-
- !!a.make(-3,-2);
- is_true(a.count = 2);
- is_true(not a.empty);
- is_true(a.lower = -3);
- is_true(a.upper = -2);
- a.put(c1,-3);
- a.put(c2,-2);
- is_true(a.item(-3) = c1);
- is_true(a.item(-2) = c2);
-
- !!a.make(-1,-2);
- is_true(a.count = 0);
- is_true(a.empty);
- is_true(a.lower = -1);
- a.add_last(c1);
- is_true(a.count = 1);
- is_true(a.item(-1) = c1);
-
- a := <<c1>>;
- is_true(a.count = 1);
- is_true(a.lower = 1);
- is_true(a.upper = 1);
- is_true(a.item(1) = c1);
- a.add_last(c2);
- is_true(a.count = 2);
- is_true(a.item(1) = c1);
- is_true(a.item(2) = c2);
-
- !!a.make(1,3);
- a.put(c2,2);
-
- !!a.make(1,3);
- a.put(c1,1);
- a.put(c2,2);
- a.put(c3,3);
- is_true(equal(a,<<c1,c2,c3>>));
- a.resize(0,4);
- is_true(a.item(0) = Void);
- is_true(a.item(1) = c1);
- is_true(a.item(2) = c2);
- is_true(a.item(3) = c3);
- is_true(a.item(4) = Void);
-
- a := <<c1,c2,c3>>;
- a.resize(0,4);
- is_true(a.item(0) = Void);
- is_true(a.item(1) = c1);
- is_true(a.item(2) = c2);
- is_true(a.item(3) = c3);
- is_true(a.item(4) = Void);
-
- a2 := <<c1>>;
- a := clone(a2);
- is_true(a.count = 1);
- is_true(a2.count = 1);
- is_true(a.item(1) = c1);
- a2.put(c2,1);
- is_true(a2.item(1) = c2);
- is_true(a.item(1) = c1);
-
- a := <<c1,c2,c3>>;
- a2 := clone(a);
- is_true(equal(a,a2));
- a.put(Void,2);
- is_true(not equal(a,a2));
-
- !!a.make(1,3);
- a.put(c2,2);
- is_true(equal(a,<<Void,c2,Void>>));
- a.put(Void,2);
- is_true(not equal(a,<<Void,c2,Void>>));
- a.make(1,3);
- is_true(a.item(1) = Void);
- is_true(a.item(2) = Void);
- is_true(a.item(3) = Void);
-
- !!a.make(2,2);
- a.force(c1,1);
- is_true(equal(a,<<c1,Void>>));
- a.force(c3,3);
- is_true(equal(a,<<c1,Void,c3>>));
-
- end;
-
- is_true(b: BOOLEAN) is
- do
- cpt := cpt + 1;
- if not b then
- std_output.put_string("TEST_ARRAY_REFERENCE : ERROR Test # ");
- std_output.put_integer(cpt);
- std_output.put_string("%N");
- else
- -- std_output.put_string("Yes%N");
- end;
- end;
-
- cpt: INTEGER;
-
- end -- class TEST_ARRAY_REFERENCE1
-